function K_NS()
{
	//global static functions class
	function K_Global(){}
	//set the second param's all property to this first param object
	K_Global.setProperty=function(obj,pro)
	{
		var key;
		for(key in pro)
		{
			obj[key]=pro[key];
		}
	}
	//return a function handle for call obj's method handle
	K_Global.getCallback=function(obj,handle){return function(){return handle.apply(obj,arguments)};}
	//check if this param is a HTML Element
	K_Global.isHtmlControl=function(obj){return (obj.tagName || obj==window || obj==document);}
	//return a browser event obj from param(if exists)
	K_Global.getEvent=function(argu)
	{
		if(!argu){argu=[];}
		if(!argu[0]){argu[0]=window.event;}
		if(argu[0] && !argu[0].target && argu[0].srcElement){argu[0].target=argu[0].srcElement};
		return argu;
	}
	//create a browser event handle adapter
	K_Global.createAdapter=function(hObj,hMethod)
	{
		return function(){hMethod.apply(hObj,K_Global.getEvent(arguments));}
	};
	//stop event bubble and return false
	K_Global.cancelBubble=function(e)
	{
		e=e?e:window.event;
		if(!e){return;}
		if(document.all)
		{
			e.cancelBubble=true;
			e.returnValue=false
		}
		else if(e.stopPropagation)
		{
			e.preventDefault();
			e.stopPropagation();
		}
	};
	//stop event bubble and return true
	K_Global.returnTrue=function(e)
	{
		e=e?e:window.event;
		if(!e){return;}
		if(document.all)
		{
			e.cancelBubble=true;
			e.returnValue=true;
		}
		else if(e.stopPropagation)
		{
			e.stopPropagation();
		}
	};
	//when "obj" trigger "event",run hobj's method(hmethod), return a event listener
	K_Global.bind=function(obj,event,hObj,hMethod)
	{
		return K_Global.addListener(obj,event,K_Global.isHtmlControl(obj)?K_Global.createAdapter(hObj,hMethod):K_Global.getCallback(hObj,hMethod));
	};
	//depose node from dom document(Html or Xml)
	K_Global.deposeNode=function(node,onlyChild)
	{
		if(!node){return;}
		if(node.parentNode && !onlyChild){node.parentNode.removeChild(node);}
		if(!onlyChild){K_Global.clearListeners(node);}
		var child;
		while(child=node.firstChild)
		{
			K_Global.deposeNode(child);
		}
	}
	//when "obj" trigger "event",run function "handle", return a event listener
	K_Global.addListener=function(obj,event,handle)
	{
		if(!K_Global._ganttUnloadListener)
		{
			K_Global._ganttUnloadListener=true;
			K_Global._ganttUnloadListener=K_Global.addListener(window,"unload",K_Global.clearAllListeners);
		}
		var listener=[obj,event];
		var type=K_Global.isHtmlControl(obj);
		if(type)
		{
			handle=K_Global.getCallback(obj,handle);
			if(obj.addEventListener){obj.addEventListener(event,handle,false);}
			else if(obj.attachEvent){obj.attachEvent("on"+event,handle);}
		}
		listener.push(handle);
		if(!K_Global.allEvents){K_Global.allEvents=[];}
		if(event!="unload"){K_Global.allEvents.push(listener);}
		return listener;
	};
	//remove a event listener
	K_Global.removeListener=function(listener)
	{
		if(!listener || listener.length==0){return;}
		if(arguments.length>1)
		{
			var listeners=arguments[0]._LT_E_;
			for(var i=0;i<listeners.length;i++){if(listeners[i][1]==arguments[1] && listeners[i][2]==arguments[2]){return K_Global.removeListener(listeners[i]);}}
		}
		try{
		if(K_Global.isHtmlControl(listener[0]))
		{
			if(listener[0].removeEventListener){listener[0].removeEventListener(listener[1],listener[2],false);}
			else if(listener[0].detachEvent){listener[0].detachEvent("on"+listener[1],listener[2]);}
		}
		var array=listener[0]._LT_E_;
		for(var i=array.length-1;i>=0;i--)
		{
			if(array[i]==listener)
			{
				array.splice(i,1);
				break;
			}
		}
		}catch(e){}
		array=K_Global.allEvents;
		for(var i=array.length-1;i>=0;i--)
		{
			if(array[i]==listener)
			{
				array.splice(i,1);
				break;
			}
		}
		while(listener.length>0){listener.pop()}
		delete listener;
	};
	//delete all obj's event
	K_Global.clearListeners=function(obj,event)
	{
		if(!obj || !obj._LT_E_){return;}
		var listener,listeners=obj._LT_E_;
		for(var i=listeners.length-1;i>=0;i--)
		{
			listener=listeners[i];
			if(!event || listener[1]==event)
			{
				K_Global.removeListener(listener);
			}
		}
	};
	//delete all events on the page
	K_Global.clearAllListeners=function()
	{
		var listeners=K_Global.allEvents;
		if(listeners)
		{
			for(var i=listeners.length-1;i>=0;i--)
			{
				K_Global.removeListener(listeners[i]);
			}
		}
		K_Global.allEvents=null;
	};
	//trigger obj's event,param args is a array as event auguments
	K_Global.trigger=function(obj,event,args)
	{
		if(K_Global.isHtmlControl(obj))
		{
			try{
			if(obj.fireEvent){obj.fireEvent("on"+event);}
			if(obj.dispatchEvent){obj.dispatchEvent(event);}
			}catch(e){}
		}
		if(!args){args=[];}
		var listeners=obj._LT_E_;
		if(listeners&&listeners.length>0)
		{
			for(var i=listeners.length-1;i>=0;i--)
			{
				var listener=listeners[i];
				if(listener && listener[2])
				{
					if(listener[1]=="*")
					{
						listener[2].apply(obj,[event,args]);
					}
					if(listener[1]==event)
					{
						listener[2].apply(obj,args);
					}
				}
			}
		}
	}
	//get obj(a html element)'s position on page body
	K_Global.getPageOffset=function(obj,container)
	{
		var point=[0,0];
		var a=obj;
		while(a && a.offsetParent && a!=container)
		{
			point[0]+=a.offsetLeft;
			point[1]+=a.offsetTop;
			a=a.offsetParent
		}
		return point;
	}
	//get event position relative to container
	K_Global.getEventPosition=function(e,container)
	{
		if(typeof e.offsetX!="undefined")
		{
			var src=e.target||e.srcElement;
			var offset=[e.offsetX,e.offsetY];
			while(src&&src!=container)
			{
				if(!(src.clientWidth==0 && src.clientHeight==0 && src.offsetParent && src.offsetParent.nodeName=="TD"))
				{
					offset[0]+=src.offsetLeft;
					offset[1]+=src.offsetTop;
				}
				src=src.offsetParent;
				if(src)
				{
					offset[0]-=src.scrollLeft;
					offset[1]-=src.scrollTop;
				}
				else
				{
					var s=K_Global.getPageOffset(container);
					return [offset[0]-s[0],offset[1]-s[1]];
				}
			}
			return offset;
		}
		else if(typeof e.pageX!="undefined")
		{
			var offset=K_Global.getPageOffset(container);
			return [e.pageX-offset[0],e.pageY-offset[1]];
		}
		else
			return [0,0];
	}
	//return the event button type of a mouse event ,1=left button,2=right button
	K_Global.getEventButton=function(e)
	{
		return document.all?e.button:(e.button==2?2:1);
	}
	//set the obj element can't be selected
	K_Global.setUnSelectable=function(obj)
	{
		if(document.all)
		{
			obj.unselectable="on";
			K_Global.addListener(obj,"selectstart",K_Global.falseFunction);
		}
		else
		{
			obj.style.MozUserSelect="text";
		}
	}
	//create a XmlHttpRequest
	K_Global.createHttpRequest=function()
	{
		if(window.XMLHttpRequest)
		{
			return new XMLHttpRequest();
		}
		else if(typeof(ActiveXObject)!="undefined")
		{
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	//load a xml
	//path:		string,		url of the xml
	//handle:	function,	the function to be call when xml loaded
	//async:	bool,		async or sync
	K_Global.loadXml=function(path,handle,async)
	{
		var doc;
		try{
			doc=K_Global.createDocument();
			doc.load(path);
		}
		catch(e){}
		if(doc && doc.documentElement)
		{
			if(handle)
			{
				handle.apply(null,[doc]);
			}
			doc=null;
			return;
		}
		var request=K_Global.createHttpRequest(),triggered=false;
		var onReadyStateChange=K_Global.getCallback(this,function()
		{
			triggered=true;
			if(request.readyState==4)
			{
				var doc=request.responseXML;
				if(!doc.documentElement)
				{
					doc=K_Global.createDocument(request.responseText);
				}
				if(!doc ||!doc.documentElement)
				{
					alert('XML 加载出错！');
					return;
				}
				if(handle)
				{
					handle.apply(null,[doc]);
				}
				doc=null;
				K_Global.clearListeners(request);
				request=null;
			}
		});
		request.onreadystatechange=onReadyStateChange;
		request.open("GET",path,!!async);
		request.send(null);
		if(!async && !triggered)
		{
			onReadyStateChange();
		}
	}
	//create a Dom Document use xml String
	K_Global.createDocument=function(xmlStr)
	{
		var doc;
		if(typeof(ActiveXObject)!="undefined"&&typeof(GetObject)!="undefined")
		{
			try{doc=new ActiveXObject("Msxml2.DOMDocument");}
			catch(e){doc=new ActiveXObject("Msxml.DOMDocument");}
			if(xmlStr)
			{
				doc.loadXML(xmlStr);
			}
		}
		else
		{
			if(xmlStr)
			{
				if(typeof DOMParser!="undefined")
				{
					doc=new DOMParser().parseFromString(xmlStr,"text/xml")
				}
			}
			else
			{
				if(document.implementation && document.implementation.createDocument)
				{
					doc=document.implementation.createDocument("","",null);
				}
			}
		}
		return doc;
	}
	//returen a value of a Xml Node
	K_Global.getNodeValue=function(node)
	{
		if(!node || typeof(node)!="object"){return node;}
		return node.text?node.text:(node.childNodes[0]?node.childNodes[0].nodeValue:"");
	}
	window.K_Global=K_Global;
}
K_NS();